<?php  

if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class search extends CI_Controller {
	function __construct()
	{
	parent::__construct();
		
		// check if salesman logged in 
		if (!$this->ion_auth->logged_in())
	  	{
			redirect('auth/login');
	  	}		
		$this->load->library('form_validation');
		$this->load->model('sales/sales_model');
		$this->load->model('purchase/purchase_model');
		//$this->load->model('people/salesman_model');		
		$this->load->library('ion_auth');
		$this->load->library('session');
		
		$this->load->library('form_validation');
		$this->load->helper('url');
			$this->load->library('datatables');
		// Load MongoDB library instead of native db driver if required
		$this->config->item('use_mongodb', 'ion_auth') ?
		$this->load->library('mongo_db') :

		$this->load->database();

		$this->form_validation->set_error_delimiters($this->config->item('error_start_delimiter', 'ion_auth'), $this->config->item('error_end_delimiter', 'ion_auth'));

	}
	
	
	function getby_code(){

	$this->data['products']= $this->sales_model->getby_code($_REQUEST['code'],$_REQUEST['name'],$_REQUEST['category'])->result();	
		$this->load->view('sales/search_list',$this->data);
	//print_r($this->data['products']);exit;		
	
	}
	
	function getby_name(){
	$this->data['products']= $this->sales_model->getby_name($_REQUEST['name'], $_REQUEST['code'], $_REQUEST['category'])->result();	
	//print_r($this->data['products']);exit;	
		$this->load->view('sales/search_list',$this->data);
	}
	
	function getby_category(){
		
	$this->data['products']= $this->sales_model->getby_category($_REQUEST['category'],$_REQUEST['code'],$_REQUEST['name'])->result();	
		$this->load->view('sales/search_list',$this->data);
	//print_r($this->data['products']);exit;	
		
	
	}

	
}

?>